//**************************柜员管理*******************************************************
function getTellerInfo(json){
	if(json.statusCode==DWZ.statusCode.error){
		navTabAjaxDone(json)
	}else{
		var content="";
		$(json).each(function(n,item){
			var numPerPage=item.numPerPage;
			var currentPage=item.currentPage;
			var totalCount=item.totalCount;
			var pageCount=item.pageCount;
			var list=item.list;
//			alert(numPerPage+","+currentPage+","+totalCount);
			if(list.length==0){
				content+="<tr><td colspan='3' align='center' >未查询到数据</td></tr>"
			}else{
				for(var i=0;i<list.length;i++){
					content+="<tr onmouseover='moveoverMouse(this)' onmouseout='moveoutMouse(this)' align='center'><td><input  name='tellerManage' onclick='test(this)' type='radio' value="+list[i].userNo+" /></td><td>"+
					list[i].userNo+"</td><td>"+list[i].userName+"</td><td><input type='button' class='newButton' value='分配网点' onclick='allotBranch(this)'></td></tr>"
				}
			}
			$("#tbodyByTeller").html(content);
			$("input[name='numPerPage']").val(numPerPage);
			$("input[name='pageNum']").val(currentPage); 
//			$("input[name='pageCount']").val(pageCount);
			$("#totalCountByTeller").text("条，共"+totalCount+"条");
//			var pagination="<a href='#' onclick="+"previous($('#getTellerInfo'),getTellerInfo) id='previous' >上一页  </a><a href='#' onclick="+"next($('#getTellerInfo'),getTellerInfo) id='next'> 下一页</a><span>当前第"+currentPage+"页，共"+pageCount+"页</span>";
//			$("#paginationByTeller").html(pagination);
			$("#paginationByTeller").addClass("pagination").attr("targetType","navTab").attr("totalCount",totalCount).attr("numPerPage",numPerPage).attr("pageNumShown","10").attr("currentPage",currentPage).attr("rel","tbodyByTeller").attr("callback","getTellerInfo");
			$("div.pagination").each(function(){
				var $this = $(this);
				$this.pagination({
					targetType:"navTab",
					rel:"tbodyByTeller",
					totalCount:totalCount,
					numPerPage:numPerPage,
					pageNumShown:10,
					currentPage:currentPage,
					callback:getTellerInfo
				});
			});
			var $p = $("#ByTellerManage");
			initUI($p);
		});
	}
	
}
//***************给柜员分配网点***************************************************************
function allotBranch(event){
	//20180913yzj修改以下行
	var parm=$(event).parent().parent().parent().find("td:eq(1)").text();
	var options=getOptionsBig();
	options.parm=parm;
	$.pdialog.open("tellerManage/allotBranch","infos", "分配网点",options);
}
//*********柜员新增和修改***********************************************************
function getUpdateTellerInfo(json){
	if(json.statusCode==DWZ.statusCode.error){
		navTabAjaxDone(json)
	}else{
		$(json).each(function(n,item){
			if(item.sign){//新增
				$("#userNo").attr("hidden",true);
				$("#initPassword").attr("hidden",true)
			}else {//修改
				if(item.allot){
					$("input").attr("readonly","readonly");
					$("#tellerPaperType").attr("disabled","disabled");
					$("input[name='gender']").attr("disabled","disabled");
					$("input[nmae='loginName']").attr("disabled","disabled");
					$("input[name='loginPassword']").parent().attr("style","display: none");
					$("input[name='loginPassword']").removeClass();
					
					
					
				}
				$("input[name='loginPassword']").removeClass("validPwdLevOne");
				$("input[name='loginPassword']").removeClass("validRequired");
				$("input[name='loginPassword']").parent().find("span").attr("hidden",true)
				$("input[name='loginName']").val(item.teller.loginName).attr("readonly","readonly");
				$("input[name='userNo']").val(item.teller.userNo); 
				$("input[name='userName']").val(item.teller.userName); 
				$("input[name='loginPassword']").val('');
				$("input[name='loginPassword']").attr("readonly","readonly")
				$("input[name='passWord']").parent().attr("style","display: none"); 
				$("input[name='passWord']").removeClass();
				//alert("证件类型"+item.teller.paperType);
				$("#tellerPaperType").val(item.teller.paperType);
				$("input[name='paperNo']").val(item.teller.paperNo);
				$("input[name='paperType']").val(item.teller.paperType);
				$("input[name='telephone']").val(item.teller.telephone);
				$("input[name='genders']").val(item.teller.gender);
				if(item.teller.gender=="01"){
					$("input[value='01']").attr("checked",true);
				}else if(item.teller.gender=="02"){
					$("input[value='02']").attr("checked",true);
				}
				if(item.teller.email!=null){
					$("input[name='email']").val(item.teller.email);
				}
				if(item.teller.headship!=null){
					$("input[name='headship']").val(item.teller.headship);
				}
				if(item.teller.responseDesc!=null){
					$("input[name='responseDesc']").val(item.teller.responseDesc);
				}
				if(item.teller.branchNo!=null){
					//alert("网点号"+item.teller.branchNo)
					$("#branchNoByTeller").val(item.teller.branchNo);
				}
				if(item.teller.takepostDate!=null){
					$("input[name='takepostTime']").val(item.teller.takepostDate);
				}
				if(item.teller.hasCertTrunk!=null){
					$("input[name='hasCertTrunk']").val(item.teller.hasCertTrunk);
				}
				if(item.teller.hasCashBox!=null){
					$("input[name='hasCashBox']").val(item.teller.hasCashBox);
				}
				if(item.teller.certName!=null){
					$("input[name='certName']").val(item.teller.certName);
				}
				if(item.teller.signStatus!=null){
					$("input[name='signStatus']").val(item.teller.signStatus);
				}
				if(item.teller.checkStatus!=null){
					$("input[name='checkStatus']").val(item.teller.checkStatus);
				}
				if(item.teller.remark!=null){
					$("input[name='remark']").val(item.teller.remark);
				}
				
			}
		});
	}
	
}

//******************************网点管理******************************************************
function getBranchInfo(json){
	if(json.statusCode==DWZ.statusCode.error){
		navTabAjaxDone(json)
	}else{
		var content="";
		$(json).each(function(n,item){
			var numPerPage=item.numPerPage;
			var currentPage=item.currentPage;
			var totalCount=item.totalCount;
			var pageCount=item.pageCount;
			var list=item.list;
//			alert(numPerPage+","+currentPage+","+totalCount);
			if(list.length==0){
				content+="<tr><td colspan='3' align='center' >未查询到数据</td></tr>"
			}else{
				for(var i=0;i<list.length;i++){
					content+="<tr onmouseover='moveoverMouse(this)' onmouseout='moveoutMouse(this)' align='center'><td><input  name='branchManage' onclick='test(this)' type='radio' value="+list[i].orgNo+" /></td><td>"+
					list[i].orgNo+"</td><td>"+list[i].orgName+"</td><td><input type='button' class='newButton' value='分配柜员' onclick='allotTeller(this)'></td></tr>"
				}
			}
			$("#tbodyByBranch").html(content);
			$("input[name='numPerPage']").val(numPerPage);
			$("input[name='pageNum']").val(currentPage); 
//			$("input[name='pageCount']").val(pageCount);
			$("#totalCountByBranch").text("条，共"+totalCount+"条");
//			var pagination="<a href='#' onclick="+"previous($('#getBranchInfo'),getBranchInfo) id='previous' >上一页  </a><a href='#' onclick="+"next($('#getBranchInfo'),getBranchInfo) id='next'> 下一页</a><span>当前第"+currentPage+"页，共"+pageCount+"页</span>";
//			$("#paginationByBranch").html(pagination);
			$("#paginationByBranch").addClass("pagination").attr("targetType","navTab").attr("totalCount",totalCount).attr("numPerPage",numPerPage).attr("pageNumShown","10").attr("currentPage",currentPage).attr("rel","tbodyByBranch").attr("callback","getBranchInfo");
			$("div.pagination").each(function(){
				var $this = $(this);
				$this.pagination({
					targetType:"navTab",
					rel:"tbodyByBranch",
					totalCount:totalCount,
					numPerPage:numPerPage,
					pageNumShown:10,
					currentPage:currentPage,
					callback:getBranchInfo
				});
			});
			var $p = $("#ByBranchManage");
			initUI($p);
		});
	}
	
}
//**********************给网点分配柜员**************************************************
function allotTeller(event){
	//20180913yzj修改以下行
	var stra=$(event).parent().parent().parent().find("td:eq(1)").text();
	var parm=stra
	var options=getOptionsSmall();
	options.parm=parm;
	$.pdialog.open("branchManage/allotTeller","infos", "分配柜员",options); 
}

//*********************分配柜员时获取柜员信息********************************************
function getTellerInfoByAllot(json){
	if(json.statusCode==DWZ.statusCode.error){
		navTabAjaxDone(json)
	}else{
		var content="";
		$(json).each(function(n,item){
			var numPerPage=item.numPerPage;
			var currentPage=item.currentPage;
			var totalCount=item.totalCount;
			var pageCount=item.pageCount;
			var list=item.list;
//			alert(numPerPage+","+currentPage+","+pageCount)
			if(list.length==0){
				content+="<tr><td colspan='3' align='center' >未查询到数据</td></tr>"
			}else{
				for(var i=0;i<list.length;i++){
					content+="<tr onmouseover='moveoverMouse(this)' onmouseout='moveoutMouse(this)' align='center'><td><input  name='allotTeller' onclick='commitByBranch(this)'  type='checkbox' value="+list[i].userNo+" /></td><td>"+
					list[i].userNo+"</td><td>"+list[i].userName+"</td></tr>"
				}
			}
			$("#tbodyByAllotTeller").html(content);
			$("input[name='numPerPage']").val(numPerPage);
			$("input[name='pageNum']").val(currentPage); 
//			$("input[name='pageCount']").val(pageCount);
			$("#totalCountByAllotTeller").text("条，共"+totalCount+"条");
//			var pagination="<a href='#' onclick="+"previous($('#getTellerInfoByAllot'),getTellerInfoByAllot) id='previous' >上一页  </a><a href='#' onclick="+"next($('#getTellerInfoByAllot'),getTellerInfoByAllot) id='next'> 下一页</a><span>当前第"+currentPage+"页，共"+pageCount+"页</span>";
//			$("#paginationByAllotTeller").html(pagination);
			$("#paginationByAllotTeller").addClass("pagination").attr("targetType","dialog").attr("totalCount",totalCount).attr("numPerPage",numPerPage).attr("pageNumShown","10").attr("currentPage",currentPage).attr("rel","tbodyByAllotTeller").attr("callback","getTellerInfoByAllot");
			$("#paginationByAllotTeller").each(function(){
				var $this = $(this);
				$this.pagination({
					targetType:"dialog",
					rel:"tbodyByAllotTeller",
					totalCount:totalCount,
					numPerPage:numPerPage,
					pageNumShown:10,
					currentPage:currentPage,
					callback:getTellerInfoByAllot
				});
			});
			var $p = $("#AllotTeller");
			initUI($p);
			//判断是否选中状态
			var branchNo=$("input[name='branchNo']").val();
			for(var i=0;i<list.length;i++){
				if(list[i].branchNo==branchNo){
					$("input[name='allotTeller']:eq("+i+")").attr("checked","checked")
				}
			}	
		});
	}
	
}
//*****************网点分配柜员时选中一个提交一个*********************************************
function commitByBranch(a){
	var branchNo=$("input[name='branchNo']").val();
	var userNo=$(a).val();
	//alert("网点编号"+branchNo)
	if($(a).attr("checked")){
		//alert("选中"+$(a).val());
		$.post("branchManage/commitAllotTeller",{branchNo:branchNo,userNo:userNo},function(json){
			$(a).attr("checked",true)
		},"json");
	}else{
		//alert("取消"+$(a).val());
		branchNo="null";
		$.post("branchManage/commitAllotTeller",{branchNo:branchNo,userNo:userNo},function(json){
			$(a).removeAttr("checked")
		},"json");
	}
	test(a)
}

//**************网点新增和修改*******************************************************************
function getUpdateBranchInfo(json){
	if(json.statusCode==DWZ.statusCode.error){
		navTabAjaxDone(json)
	}else{
		$(json).each(function(n,item){
			if(item.sign){
				//新增网点
				$("#orgNo").attr("hidden",true);
				$("input[name='applyTime']").val(getDate(Date.now()));
			}else{
				//修改网点
				$("input[name='orgNo']").val(item.branch.orgNo); 
				$("input[name='orgName']").val(item.branch.orgName); 
				$("select[name='type']").val(item.branch.type);
				$("select[name='property']").val(item.branch.property);
				$("input[name='leadName']").val(item.branch.leadName);
				$("select[name='leadPaperType']").val(item.branch.leadPaperType);
				$("input[name='leadPaperNo']").val(item.branch.leadPaperNo);
				$("input[name='linkMan']").val(item.branch.linkMan);
				$("input[name='telephone']").val(item.branch.telephone);
				$("input[name='address']").val(item.branch.address);
//				alert("item.branch.innerNo"+item.branch.innerNo)
//				alert("item.branch.serverType"+item.branch.serverType)
//				alert("item.branch.serverDate"+item.branch.serverDate)
//				alert("item.branch.serverDate.split('-')[0]"+item.branch.serverDate.split("-")[0])
				if(item.branch.serverDate!=null){
					$("select[name='innerNo']").val(item.branch.innerNo);
					$("select[name='serverType']").val(item.branch.serverType);
					$("#timePicker1").val(item.branch.serverDate.split("-")[0]);
					$("#timePicker2").val(item.branch.serverDate.split("-")[1]);
				}
				if(item.branch.fax!=null){
					$("input[name='fax']").val(item.branch.fax);
				}
				if(item.branch.email!=null){
					$("input[name='email']").val(item.branch.email);
				}
				if(item.branch.postcode!=null){
					$("input[name='postcode']").val(item.branch.postcode);
				}
				if(item.branch.street!=null){
					$("select[name='street']").val(item.branch.street);
				}
				if(item.branch.community!=null){
					$("input[name='community']").val(item.branch.community);
				}
				
				$("input[name='region']").val(item.branch.region);
				
				if(item.branch.innerNo!=null){
					$("input[name='innerNo']").val(item.branch.innerNo);
				}
				
				$("input[name='principal']").val(item.branch.principal);
				$("select[name='status']").val(item.branch.status);
				$("input[name='checkStatus']").val(item.branch.checkStatus);
				$("input[name='applyTime']").val(getDate(item.branch.applyDate));
				if(item.branch.bankName!=null){
					$("input[name='bankName']").val(item.branch.bankName);
					$("input[name='bankBranchName']").val(item.branch.bankBranchName);
					$("input[name='bankAccountCode']").val(item.branch.bankAccountCode);
					$("input[name='bankAccountName']").val(item.branch.bankAccountName);
					
				}
				$("input[name='enterCode']").val(item.branch.enterCode);
				if(item.branch.activeDate!=null){
					$("input[name='activeTime']").val(getDate(item.branch.activeDate));
				}
				if(item.branch.superIorOrg!=null){
					$("input[name='superIorOrg']").val(item.branch.superIorOrg);
				}
				if(item.branch.laeDate!=null){
					$("input[name='laeTime']").val(getDate(item.branch.laeDate));
				}
				if(item.branch.laeCircs!=null){
					$("input[name='laeCircs']").val(item.branch.laeCircs);
				}
				if(item.branch.remark!=null){
					$("input[name='remark']").val(item.branch.remark);
				}	
			}
		});
	}
	
}

//**************柜员授权获取柜员信息*****************************************************
function getInfoByTellerAccredit(item){
	if(item.statusCode==DWZ.statusCode.error){
		navTabAjaxDone(item)
	}else{
		var content="";
		var numPerPage=item.numPerPage;
		var currentPage=item.currentPage;
		var totalCount=item.totalCount;
		var pageCount=item.pageCount;
		var list=item.list;
		if(list.length==0){
			content+="<tr><td colspan='3' align='center' >未查询到数据</td></tr>"
		}else{
			for(var i=0;i<list.length;i++){
				var branchName="";
				if(list[i].branchName!=null){
					branchName=list[i].branchName;
				}
				content+="<tr onmouseover='moveoverMouse(this)' onmouseout='moveoutMouse(this)' align='center'><td>"+
				list[i].userNo+"</td><td>"+list[i].userName+"</td><td>"+branchName+"</td><td><input class='newButton' type='button' value='角色设置' onclick='roleSet(this)'><input type='hidden' value='"+list[i].userId+"'></td></tr>"
			}
		}
		$("#tbodyByTellerAccredit").html(content);
		$("input[name='numPerPage']").val(numPerPage);
		$("input[name='pageNum']").val(currentPage); 
//		$("input[name='pageCount']").val(pageCount);
		$("#totalCountByTellerAccredit").text("条，共"+totalCount+"条");
//		var pagination="<a href='#' onclick="+"previous($('#getInfoByTellerAccredit'),getInfoByTellerAccredit) id='previous' >上一页  </a><a href='#' onclick="+"next($('#getInfoByTellerAccredit'),getInfoByTellerAccredit) id='next'> 下一页</a><span>当前第"+currentPage+"页，共"+pageCount+"页</span>";
//		$("#paginationByTellerAccredit").html(pagination);
		$("#paginationByQueryMakeCardTask").addClass("pagination").attr("targetType","navTab").attr("totalCount",totalCount).attr("numPerPage",numPerPage).attr("pageNumShown","10").attr("currentPage",currentPage).attr("rel","tbodyByTellerAccredit").attr("callback","getInfoByTellerAccredit");
		$("div.pagination").each(function(){
			var $this = $(this);
			$this.pagination({
				targetType:"navTab",
				rel:"tbodyByTellerAccredit",
				totalCount:totalCount,
				numPerPage:numPerPage,
				pageNumShown:10,
				currentPage:currentPage,
				callback:getInfoByTellerAccredit
			});
		});
		var $p = $("#ByTellerAccredit");
		initUI($p);
	}
	
}